<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="author" content="CYW">
    <title></title>
    <style>
        .box {
            margin: 100px auto;
            width: 1100px;
            height: 460px;
            position: relative;
            border: 1px solid red;
        }

        ul {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        img {
            width: 1100px;
            height: 460px;
        }

        li {
            position: absolute;
            display: none;
        }

        .current {
            display: block;
        }

        .radio {
            position: absolute;
            left: 500px;
            bottom: 50px;
            display: block;
            background-color: transparent;
        }

        .one {
            background-color: red;
        }
        span.left-arrows,
        span.right-arrows{
            line-height: 70px;
            text-align: center;
            position: absolute;
            width: 50px;
            height: 70px;
            background-color:salmon;
             display:none; 
        }
        .left-arrows{
            left: 0;
            top:180px;
        }
        .right-arrows{
            right: 0;
             top:180px;
        }
    </style>
</head>

<body>
    <main>
        <div class="box">
            <ul>
                <li class="current"><a href="#"><img src="./小米轮播/1.jpg" alt=""></a></li>
                <li><a href="#"><img src="./小米轮播/2.jpg" alt=""></a></li>
                <li><a href="#"><img src="./小米轮播/3.jpg" alt=""></a></li>
                <li><a href="#"><img src="./小米轮播/4.jpg" alt=""></a></li>
                <li><a href="#"><img src="./小米轮播/5.jpg" alt=""></a></li>
            </ul>
            <div class="radio">
                <button type="radio" class="one"></button>
                <button type="radio"></button>
                <button type="radio"></button>
                <button type="radio"></button>
                <button type="radio"></button>
            </div>
            <span class='left-arrows'>&lt;</span>
            <span class='right-arrows'>&gt;</span>
        </div>
    </main>

</body>

</html>
<script>
    var lis = document.querySelectorAll('li');
    var buts = document.querySelectorAll('button');
    var leftArrows=document.querySelector('.left-arrows');
    var rightArrows=document.querySelector('.right-arrows');
    var div = document.querySelector('.box');
    var index = 0;
    setInterval(changeImage, 1000);
    function changeImage() {
        for (var i = 0; i < lis.length; i++) {
            lis[i].className = '';
            buts[i].className='';
        }
        index++;
        if (index == 5) {
            index = 0
        }
        console.log(index);
        lis[index].className = 'current';
        buts[index].className='one'
    }

    div.onmouseenter = function(){
            leftArrows.style.display = 'block';
            rightArrows.style.display = 'block';            
    }
    div.onmouseleave = function(){
            leftArrows.style.display = 'none';
            rightArrows.style.display = 'none'; 
    }

</script>